<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$cfg[titles]}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  <meta name="renderer" content="webkit">
  <link rel="shortcut icon" type="image/x-icon" href= "{$cfg[webdir]}favicon.ico" />
  <link rel="stylesheet" href="{$cfg[tpl]}user/css/frontend.min.css" media="all">
  <link rel="stylesheet" href="{$cfg[tpl]}user/css/user.css" media="all">
  <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
  <!--[if lt IE 9]>
  <script src="{$cfg[tpl]}user/js/html5shiv.js"></script>
  <script src="{$cfg[tpl]}user/js/respond.min.js"></script>
  <![endif]-->
  <script src="{$cfg[webdir]}static/js/jquery.js" charset="utf-8"></script>
  <script src="{$cfg[tpl]}user/js/bootstrap.min.js"></script>
</head>
<body>
  <nav class="navbar navbar-white navbar-fixed-top" role="navigation">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#header-navbar">
          <span class="sr-only">{lang:toggle}</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="{$cfg[weburl]}">{$cfg[webname]}</a>
      </div>
      <div class="collapse navbar-collapse" id="header-navbar">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="{$cfg[weburl]}" title="{$cfg[webname]}">{lang:home}</a></li>
        </ul>
      </div>
    </div>
  </nav>

  <main class="content">
    <div id="content-container" class="container">
      <div class="user-section login-section">
        <div class="logon-tab clearfix">
          {if:$cfg[open_user_login]}<a href="{$login_url}" title="{lang:login}" rel="nofollow">{lang:login}</a>{/if}
          <a class="active" title="{lang:register}" rel="nofollow">{lang:register}</a>
        </div>
        <div class="login-main">
          <form id="login-form" class="form-horizontal layui-form" action="{$register_url}" method="post">
            <input type="hidden" name="FORM_HASH" value="{$form_hash}" />
            <div class="form-group">
              <label for="username" class="col-sm-4 control-label">{lang:username}</label>
              <div class="col-sm-8">
                <input class="form-control" id="username" type="text" name="username" value="" placeholder="{lang:please_input_username}" autocomplete="off">
              </div>
            </div>

            <div class="form-group">
              <label for="password" class="col-sm-4 control-label">{lang:password}</label>
              <div class="col-sm-8">
                <input class="form-control" id="password" type="password" name="password" value="" placeholder="{lang:please_input_password}" autocomplete="off">
              </div>
            </div>

            <div class="form-group">
              <label for="repassword" class="col-sm-4 control-label">{lang:confirm_new_password}</label>
              <div class="col-sm-8">
                <input class="form-control" id="repassword" type="password" name="repassword" value="" placeholder="{lang:please_input_password}" autocomplete="off">
              </div>
            </div>

            {if:$cfg[open_user_register_vcode]}
            <div class="form-group">
              <label for="vcode" class="col-sm-4 control-label">{lang:vcode}</label>
              <div class="col-sm-4">
                <input class="form-control" id="vcode" type="text" name="vcode" value="" placeholder="{lang:vcode}" autocomplete="off">
              </div>
              <div class="col-sm-4">
                <img src="index.php?user-vcode-name-registervcode.html" alt="{lang:vcode}" onclick="this.src='index.php?user-vcode-name-registervcode-r-'+Math.random();" id="vcodeimg" style="width: 100%;" />
              </div>
            </div>
            {/if}
            {hook:user_register_item_end.htm}
            <div class="form-group">
              <label class="col-sm-4 control-label"></label>
              <div class="col-sm-8">
                <button type="submit" class="btn btn-primary btn-lg btn-block" lay-submit lay-filter="form">{lang:submit}</button>
                {if:$cfg[open_user_login]}<a href="{$login_url}" title="{lang:login}" rel="nofollow" class="btn btn-default btn-lg btn-block mt-3 no-border">{lang:login_tips}</a>{/if}
              </div>
            </div>
            {hook:user_user_register_after.htm}
          </form>
        </div>
      </div>
    </div>
  </main>

  <footer class="footer" style="clear:both">
    <p class="copyright">Copyright&nbsp;©&nbsp;{php}echo date('Y');{/php} {$cfg[webname]} All Rights Reserved.</p>
  </footer>

  <script src="{$cfg[webdir]}static/layui/lib/layui-v2.8.15/layui.js" charset="utf-8"></script>
  <script type="text/javascript">
    layui.use(['form'], function () {
      var form = layui.form, layer = layui.layer, $ = layui.$;

      form.on('submit(form)', function (data) {
        data = data.field;
        if (data.username == '') {
          layer.msg('{lang:please_input_username}', {icon: 5});
          return false;
        }else if (data.password == '') {
          layer.msg('{lang:please_input_password}', {icon: 5});
          return false;
        }else if (data.repassword == '') {
          layer.msg('{lang:please_input_confirm_password}', {icon: 5});
          return false;
        }else if(data.password != data.repassword){
          layer.msg('{lang:pwd_inconsistent}', {icon: 5});
          return false;
        }
        $.post("index.php?user-register-ajax-1",data,function(res){
          if(res.status){
            var icon = 1;
          }else{
            var icon = 5;
          }
          layer.msg(res.message, {icon: icon});
          if(res.status) setTimeout(function(){ location.href="{$_http_referer}"; }, 1000);
          return false;
        },'json');
        return false;
      });
    });
  </script>
</body>
</html>